class smx_web {
  require smx_os

  $base_web_packages = [
    'httpd',
  ]

  package { $base_web_packages :
    ensure => installed,
  }

  service { 'httpd' :
    ensure => running,
    enable => true,
  }

  file { '/vagrant/vagrant/vhost-local.conf':
    ensure => file,
    mode   => 644, owner => root, group => root,
    source =>  "puppet:///modules/smx_web/vhost-local.conf",
  }
  file { '/vagrant/vagrant/api.json':
    ensure => file,
    mode   => 644, owner => root, group => root,
    source =>  "puppet:///modules/smx_web/api.json",
  }

  file { '/vagrant/vagrant/svcconfig/httpd_config':
    ensure => directory,
    mode   => 755, owner => root, group => root,
  }

  file { '/vagrant/vagrant/svcconfig/httpd_config/ssl.conf':
    ensure  => file,
    mode    => 644, owner => root, group => root,
    source  =>  "puppet:///modules/smx_web/ssl.conf",
    require => File['/vagrant/vagrant/svcconfig/httpd_config'],
  }

  file { '/vagrant/vagrant/svcconfig/httpd_config/foxitcloud.crt':
    ensure  => file,
    mode    => 644, owner => root, group => root,
    source  =>  "puppet:///modules/smx_web/foxitcloud.crt",
    require => File['/vagrant/vagrant/svcconfig/httpd_config'],
  }

  file { '/vagrant/vagrant/svcconfig/httpd_config/foxitcloud.key':
    ensure  => file,
    mode    => 644, owner => root, group => root,
    source  =>  "puppet:///modules/smx_web/foxitcloud.key",
    require => File['/vagrant/vagrant/svcconfig/httpd_config'],
  }

  file { '/vagrant/vagrant/svcconfig/httpd_config/api.conf':
    ensure  => file,
    mode    => 644, owner => root, group => root,
    source  =>  "puppet:///modules/smx_web/api.conf",
    require => File['/vagrant/vagrant/svcconfig/httpd_config'],
  }
  file { '/vagrant/webapp':
    ensure => directory,
    mode   => 755,
  }

  file { ['/vagrant/webapp/connectedpdfapp/web/dll-config','/vagrant/webapp/connectedpdfapp/web/dll-config/1.0']:
    ensure => directory,
    mode   => 755,
  }

  file { '/vagrant/webapp/connectedpdfapp/web/dll-config/1.0/cpdfApi.json':
    ensure  => file,
    mode    => 755, owner => vagrant, group => vagrant,
    source  =>  "puppet:///modules/smx_web/cpdfApi.json",
    require => File['/vagrant/webapp/connectedpdfapp/web/dll-config/1.0'],
  }

  file { '/var/lib/foxit_ucx':
    ensure  => 'link',
    target  => '/vagrant/webapp',
    require => File['/vagrant/webapp'],
  }

}
